import React, {
    Component
} from 'react';
import {
    Menu,
    Icon
} from 'antd';
import "../assets/css/Slider.css"

import {
    Link
} from 'react-router-dom'

// const { SubMenu } = Menu;
class Sider extends Component {

    constructor(props) {
        super(props);
        this.state = {
            mode: 'inline',
            theme: 'light',
            defaultOpenKeys: '1'
        }
    }

    // 组件刚开会加载
    componentWillMount() {

        let url = window.location.href;
        //停车场管理
        let parKingManage = /.*(parKingManage).*/;
        // 意见反馈
        let suggestionBack = /.*(suggestionBack).*/;
        // 客服电话
        // let phone = /.*(phone).*/;
        let carManagement = /.*(carManagement).*/;
        let AppManagement = /.*(AppManagement).*/;
        let appealMangement = /.*(appealMangement).*/;

        let lock = '1';

        switch (true) {
            case parKingManage.test(url):
                lock = '1';
                break;
            case suggestionBack.test(url):
                lock = '2';
                break;
            // case phone.test(url):
            //     lock = '3';
            //     break;

            case carManagement.test(url):
                lock = '4';
                break;
            case AppManagement.test(url):
                lock = '5';
                break;
            case appealMangement.test(url):
                lock = '6';
                break;
            default:
                break;
        }

        // 根据url 来判断是否打开的是哪个
        this.setState({
            defaultOpenKeys: lock,
        })
    }


    render() {
        return (
            <div>
                <div className="imgbox" > <img src={require('../assets/img/parking.png')}
                    alt="" />
                </div>
                <Menu className="MenuSlide" style={{ width: 230 }} defaultSelectedKeys={[this.state.defaultOpenKeys]}
                    defaultOpenKeys={
                        ['sub1']
                    }
                    mode={
                        this.state.mode
                    }
                    theme={
                        this.state.theme
                    } >
                    <Menu.Item key="1" style={{ paddingLeft: 40}} >
                        <Link to="/parKingManage" >
                           &nbsp; &nbsp; <Icon type="mail" />
                            停车场管理 </Link> </Menu.Item >
                    <Menu.Item key="2" >
                        <Link to="/suggestionBack" >
                            <Icon type="calendar" />
                           
                            意见反馈 </Link>
                    </Menu.Item >
                    { /*<Menu.Item key="3">*/}
                    { /*<Link to="/phone">*/}
                    { /*<Icon type="phone"/>*/}
                    { /*客服电话<span className="opcity">理</span>*/}
                    { /*</Link>*/}
                    { /*</Menu.Item>*/}
                    <Menu.Item key="4">
                        <Link to="/carManagement" >
                            <Icon type="bars" />
                            车辆信息 </Link>
                    </Menu.Item >
                    <Menu.Item key="5">
                        <Link to="/AppManagement" >
                        <Icon type="mobile" />版本信息 </Link>
                    </Menu.Item >
                    <Menu.Item key="6">
                        <Link to="/appealMangement" >
                        <Icon type="solution" />申诉管理 </Link>
                    </Menu.Item >

                </Menu>


            </div>
        );
    }
}


export default Sider;